/**
 * 
 */
package messenger;

/**
 * @author (Group 42) William Orem, Joseph Hamilton, Kevin Benik
 * 
 */
public class ChatManager {

	static String ValidIpAddressRegex = "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$";

	static String ValidHostnameRegex = "^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\\-]*[A-Za-z0-9])$";

	static String serverIP = "127.0.0.1";
	/**
	 * @param args
	 */
	public static void main(String[] args) {

		if(args.length==0){
			System.out.println("need -console or -gui. -ip <address or hostname> optional");
			System.exit(0);
		}
			
		boolean GUI = true;
		for(String i :args){
			if(i.contains("-gui"))
				GUI=true;
			if(i.contains("-console"))
				GUI=false;
			if(i.contains("-ip")){
				for(String s : args)
					if(s.matches(ValidIpAddressRegex)|s.matches(ValidHostnameRegex))
						serverIP=s;
			}
		}
		
		if (!GUI) {
			UserInterface uI = new UserInterface();
			uI.uiMain();
		} else {
			gui.guiMain();
		}
	}
}
